﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WS.EKA.FJYCM.Business;
using System.Text;

namespace WS.EKA.FJYCM.WebUI.UserControls
{
    public partial class DeviceTypePercent : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            rptDevice.DataSource = DeviceTypePercentList;
            rptDevice.DataBind();
        }

        public List<WS.EKA.FJYCM.Business.Model.DeviceTypePercent> DeviceTypePercentList
        {
            get
            {
                return IncidentAccess.GetMonthlyDeviceTypePercentList(3);
            }
        }
        public string DeviceData
        {
            get
            {
                var list = DeviceTypePercentList.Select(t => string.Format("['{0}',{1}]", t.Type, Convert.ToInt32(t.Total)));
                StringBuilder json = new StringBuilder();
                json.Append("[");
                json.Append(string.Join(",", list));
                json.Append("]");
                return json.ToString();
            }
        }
    }
}